import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import BusinessList from '../views/BusinessList'
import BusinessInfo from '../views/BusinessInfo'
import Login from '../views/Login'
import Orders from '../views/Orders'
import UserAddress from '../views/UserAddress'
import Payment from '../views/Payment'
import HistoryOrders from '../views/HistoryOrders'
import Register from '../views/Register'
import AddAddress from '../views/AddAddress'
import EditAddress from '../views/EditAddress'
import Mine from'../views/Mine'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Home
  },
  {
    path: '/mine',
    name: 'Mine',
    component: Mine
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path:'/businesslist',
    name:'BusinessList',
    component:BusinessList
  },
  {
    path:'/businessinfo',
    name:'BusinessInfo',
    component:BusinessInfo
  },
  {
    path:'/login',
    component:Login
  },
  {
    path:'/orders',
    component:Orders
  },
  {
    path:'/useraddress',
    component:UserAddress
  },
  {
    path:'/payment',
    component:Payment
  },
  {
    path:'/historyorders',
    component:HistoryOrders
  },
  {
    path:'/register',
    component:Register
  },
  {
    path:'/addaddress',
    component:AddAddress
  },
  {
    path:'/editaddress',
    component:EditAddress
  }
]

//解决重复路由报异常问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}


const router = new VueRouter({
  routes
})

export default router
